package com.heima.behavior.controller.v1;

import com.heima.behavior.service.BehaviorService;
import com.heima.model.behavior.dtos.CollectionBehaviorDto;
import com.heima.model.behavior.dtos.LikesBehaviorDto;
import com.heima.model.behavior.dtos.ReadBehaviorDto;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("api/v1")
@Api(value = "用户行为")
public class BehaviorController {
    @Autowired
    private BehaviorService behaviorService;

    @PostMapping("/likes_behavior")
    @ApiOperation("点赞或取消点赞")
    public ResponseResult likesBehavior(@RequestBody @Validated LikesBehaviorDto dto) {
        return behaviorService.likesBehavior(dto);
    }

    @PostMapping("/read_behavior")
    @ApiOperation("保存阅读行为")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDto dto) {
        return behaviorService.readBehavior(dto);
    }

    @PostMapping("/un_likes_behavior")
    @ApiOperation(value = "保存或取消 不喜欢行为")
    public ResponseResult unLikesBehavior(@RequestBody @Validated UnLikesBehaviorDto dto) {
        return behaviorService.unLikesBehavior(dto);
    }

    @PostMapping("/collection_behavior")
    @ApiOperation("保存或取消 收藏行为")
    public ResponseResult collectionBehavior(@RequestBody @Validated CollectionBehaviorDto dto) {
        return behaviorService.collectionBehavior(dto);
    }
}
